/**
 * 
 */
package com.wsj.dao.hibernate;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wsj.dao.ICmQuotedCompanyDao;
import com.wsj.web.vo.homeSite.CmQuotedCompany;

/**
 * @author fengbin  createTime:2009-7-25
 *  上市公司dao
 */
public class CmQuotedCompanyDaoImpl extends HibernateDaoSupport  implements ICmQuotedCompanyDao {

	/********
	 * 通过id,获取上市公司对象
	 */
	public CmQuotedCompany getCmQuotedCompanyById(int cmQuotedCompanyId) throws DataAccessException {
		
		 return  (CmQuotedCompany) this.getHibernateTemplate().get(CmQuotedCompany.class, cmQuotedCompanyId);
	}

	/********
	 * 通过股票数字代码,获取上市公司对象
	 */
	@SuppressWarnings("unchecked")
	public CmQuotedCompany loadCmQuotedCompanyByStockNumId(String stockNumId) throws DataAccessException {
		
		 List<CmQuotedCompany> cmQuotedCompanyList = this.getHibernateTemplate().find(" from CmQuotedCompany c where c.stockNumId = ?",stockNumId);
		 
		 CmQuotedCompany cmQuotedCompany = null;
		 if(cmQuotedCompanyList!=null  && !cmQuotedCompanyList.isEmpty()) {
			 cmQuotedCompany = cmQuotedCompanyList.get(0);
		 }
		 
		 return  cmQuotedCompany;
		
		 
	}

}
